package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysWindSummary;
import com.ruoyi.system.service.ISysWindSummaryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 风向风速统计Controller
 *
 * @author ruoyi
 * @date 2023-12-04
 */
@RestController
@RequestMapping("/system/summary")
public class SysWindSummaryController extends BaseController
{
    @Autowired
    private ISysWindSummaryService sysWindSummaryService;

    /**
     * 查询风向风速统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:summary:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysWindSummary sysWindSummary)
    {
        startPage();
        List<SysWindSummary> list = sysWindSummaryService.selectSysWindSummaryList(sysWindSummary);
        return getDataTable(list);
    }

    /**
     * 导出风向风速统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:summary:export')")
    @Log(title = "风向风速统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysWindSummary sysWindSummary)
    {
        List<SysWindSummary> list = sysWindSummaryService.selectSysWindSummaryList(sysWindSummary);
        ExcelUtil<SysWindSummary> util = new ExcelUtil<SysWindSummary>(SysWindSummary.class);
        util.exportExcel(response, list, "风向风速统计数据");
    }

    /**
     * 获取风向风速统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:summary:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysWindSummaryService.selectSysWindSummaryById(id));
    }

    /**
     * 新增风向风速统计
     */
    @PreAuthorize("@ss.hasPermi('system:summary:add')")
    @Log(title = "风向风速统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWindSummary sysWindSummary)
    {
        return toAjax(sysWindSummaryService.insertSysWindSummary(sysWindSummary));
    }

    /**
     * 修改风向风速统计
     */
    @PreAuthorize("@ss.hasPermi('system:summary:edit')")
    @Log(title = "风向风速统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWindSummary sysWindSummary)
    {
        return toAjax(sysWindSummaryService.updateSysWindSummary(sysWindSummary));
    }

    /**
     * 删除风向风速统计
     */
    @PreAuthorize("@ss.hasPermi('system:summary:remove')")
    @Log(title = "风向风速统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysWindSummaryService.deleteSysWindSummaryByIds(ids));
    }
}
